//
//  UIButton+Extension.swift
//  Weibo
//
//  Created by Holfioo on 15/9/8.
//  Copyright © 2015年 Holfioo. All rights reserved.
//

import UIKit


extension UIButton {
    
    convenience init(title: String, imageName: String, color: UIColor, fontSize: CGFloat) {
        // 自身初始化
        self.init()
        
        setTitle(title, forState: UIControlState.Normal)
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setTitleColor(color, forState: UIControlState.Normal)
        // 设置字体大小。
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
    }
    
    // 设置按钮的图片
    convenience init(imageName: String) {
        self.init()
        
        setImage(UIImage(named:imageName), forState: UIControlState.Normal)
        setImage(UIImage(named:imageName + "_highlighted"), forState: UIControlState.Highlighted)
        // 设置大小合适。
        sizeToFit()
    }
}